package cn.qvtu.game.control;

import cn.qvtu.game.model.Enemy;

public class EnemyController implements Runnable {
    private Enemy enemy;
    public EnemyController(Enemy enemy) {
        this.enemy = enemy;
    }
    @Override
    public void run() {
        while (true) {
            try {
                if (enemy.getStatus() == 1 || enemy.getStatus() == -1){
                    enemy.setStatus(-2);//站立状态改为左跑状态
                }
                if (enemy.getX() <= -100){
                    enemy.setStatus(2);//左跑状态改为右跑状态
                }
                if (enemy.getX() >= 550){
                    enemy.setStatus(-2);//右跑状态改为左跑状态
                }
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
